package javase.javase01.exercise08;

/**
 * @author: Gan
 * @date 2021/4/20 0020 20:19
 * @description: **2.现在有T1、T2、T3三个线程，你怎样保证T2在T1执行完后执行，T3在T2执行完后执行？**
 * 利用线程控制API
 **/
public class WorkDemo {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> System.out.println("T1执行。"));
        t1.start();
        Thread t2 = new Thread(() -> {
            try {
                t1.join();//t1插队
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("T2执行。");
        });
        t2.start();
        new Thread(() -> {
            try {
                t2.join();//t2插队
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("T3执行了。");
        }).start();

    }
}
